package com.klhappy.houyuan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.klhappy.houyuan.R;
import com.klhappy.houyuan.bean.MoneyBean.Records;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by MrPu on 15/12/21.
 */
public class ExMoAdapter extends BaseAdapter {

    private List<Records> records;
    private Context context;

    public ExMoAdapter(List<Records> records, Context context) {
        this.records = records;
        this.context = context;
    }

    @Override
    public int getCount() {
        return records.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder holder;
        if (view == null){
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.item_ex_mo ,null);
            holder.setView(view);
            view.setTag(holder);
        }else{
            holder = (ViewHolder) view.getTag();
        }

        holder.tv_time.setText(records.get(position).getMonth());
        holder.tv_yeji.setText(records.get(position).getMoneys() + "元");
        holder.tv_ticheng.setText(records.get(position).getOr_amount() + "元");
        return view;
    }

    class ViewHolder{
        @InjectView(R.id.tv_time)
        TextView tv_time;
        @InjectView(R.id.tv_yeji)
        TextView tv_yeji;
        @InjectView(R.id.tv_ticheng)
        TextView tv_ticheng;

        public void setView(View view){
            ButterKnife.inject(this ,view);}
    }
}
